class Solution
{
public:
    double calculateTax(vector<vector<int>> &brackets, int income)
    {
        int lastUpper = 0;
        double result = 0.0;
        for (auto &bracket : brackets)
        {
            int upper = bracket[0];
            int percent = bracket[1];
            if (income > upper)
            {
                result += (upper - lastUpper) * 0.01 * percent;
            }
            else
            {
                result += (income - lastUpper) * 0.01 * percent;
                break;
            }
            lastUpper = upper;
        }
        return result;
    }
};